#include"Task.h"

Task::Task(Function&& func) :func_(func){}

Task::Task(Function&& func, const std::string& descriptor) :
	func_(std::move(func)), descriptor_(descriptor)
{
}

Task::Task(Function&& func, const char* filename, const char* fn, int line) :
	func_(std::move(func)), descriptor_("")
{
	descriptor_ += "filename: ";
	descriptor_.append(filename, strlen(filename));
	descriptor_ += " func: ";
	descriptor_.append(fn, strlen(fn));
	descriptor_ += " line: " + std::to_string(line);
}

Task::Task(Task&& task)noexcept :
	func_(std::move(task.func_)),
	descriptor_(std::move(task.descriptor_)) {
}

Task::Task(const Task& task)noexcept :
	func_(task.func_),
	descriptor_(task.descriptor_) {
}

Task& Task::operator=(const Task& task)noexcept {
	func_ = task.func_;
	descriptor_ = task.descriptor_;
	return *this;
}

Task& Task::operator=(Task&& task)noexcept {
	func_ = std::move(task.func_);
	descriptor_ = std::move(task.descriptor_);
	return *this;
}

Task::~Task() {

}

void Task::operator()()const {
	return func_();
}